<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>根据兄弟元素的数量设置样式</title>
    <link rel="stylesheet" href="../public.css">
    <style>
        .box {
            width: 80%;
            margin: 20px auto;
        }

        .box li {
            text-align: center;
            line-height: 50px;
            list-style: none;
        }

        /* li:first-child:nth-last-child(5),
        li:first-child:nth-last-child(5)~li {
            width: 50px;
            height: 50px;
            background: red;

        } */
        li:first-child:nth-last-child(n+2):nth-last-child(-n+6),
        li:first-child:nth-last-child(n+2):nth-last-child(-n+6)~li {
            width: 50px;
            height: 50px;
            background: red;
        }
    </style>
</head>

<body>
    <div class="content">
        <h1></h1>
        <div class="box">
            <ul>
                <li>1</li>
                <li>2</li>
                <li>3</li>
                <li>4</li>
                <li>5</li>
                <li>1</li>
            </ul>
        </div>
    </div>
</body>

</html>